/*
\ brief:  实现文件
\ author: 清晨与猫鱼
*/
#include <iostream>         // 引入标准输入输出库
#include <string>           // 引入字符串库

using namespace std;        // 引用标准空间


/*
由于c++没有 java的Cloneable 类 所以改边一下它的实现方式。原形模式就是复制自身
*/

/*
\ brief:   形状抽象接口类
\ author: 清晨与猫鱼
*/
class Shape {
public:
    explicit Shape(string t) 
        : type_(move(t)) {            
    }

    void setId(string id) {
        id_ = move(id);
    }

    string& getId() {
        return id_;
    }

    string& getType() {
        return type_;
    }

    virtual void draw() = 0;
    virtual Shape* clone() = 0;     // 虚函数接口克隆自身
protected:
    string type_;

private:
    string id_;
};



/*
\ brief:   长方形
\ author: 清晨与猫鱼
*/
class Rectangle 
    : public Shape {
public:
    explicit Rectangle()
        : Shape("Rectangle") {            
    }

    void draw() {
        cout << "Inside Rectangle::draw() method." << endl;
    }

    Rectangle* clone() {
        return new Rectangle;
    }
};


/*
\ brief:  正方形
\ author: 清晨与猫鱼
*/
class Square 
    : public Shape {
public:
    explicit Square()
        : Shape("Square") {            
    }

    void draw() {
         cout << "Inside Square::draw() method." << endl;
    }

    Square* clone() {
        return new Square;
    }
};



/*
\ brief:  圆形
\ author: 清晨与猫鱼
*/
class Circle 
    : public Shape {
public:
    explicit Circle()
        : Shape ("Square") {            
    }

     void draw() {
         cout << "Inside Circle::draw() method." << endl;
    }

    Circle* clone() {
        return new Circle;
    }
};



